package com.fer.t1.server.fbConnect;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * The {@link OAuthRedirectServlet} represents the initial servlet who will
 * be called to initialize the OpenID authentication process with Facebook 
 * @author mono
 *
 */
public abstract class OAuthRedirectServlet{


	public final static String PERM_EMAIL = "email";
	public final static String PERM_BIRTH = "user_birthday";
	public final static String PERM_FRIENDS_ABOUT_ME = "friends_about_me";

	/**
	 * This method is typically called by the servlet using the OAuthRedirectServlet
	 * it calls the facebook OAuth url. 
	 * A typical use case 
	 * @param req
	 * @param resp
	 * @param permisionList
	 * @throws ServletException
	 * @throws IOException
	 */
	public void doGet(HttpServletRequest req, HttpServletResponse resp, String permisionList)
			throws ServletException, IOException {

		resp.sendRedirect("https://www.facebook.com/dialog/oauth?"+

					"client_id="+FB.appId+
					"&redirect_uri="+FB.redirect_uri+
					"&scope="+permisionList+
					"&state="+FB.generateString());

	}

	/**
	 * 
	 * @return
	 */
	public abstract String getFinalAuthServletURL();
}
